home *** CD-ROM | disk | FTP | other *** search
- #
- # mark the choices sent by the form for the current item in the session db
- # marker Title
- $TITLE="Catalog Maker Product Mark";
- ###############################
- # END OF CHANGEABLE OPTIONS #
- ###############################
-
- # START MAIN PROGRAM
- # ------------------
-
- &ReadParse;
- $Session = $in{'SessionID'};
- if ($Session eq '') {&PrintError; exit 1;} # An Error
- elsif ($Session eq '*SeSiOnId*') {&PrintError; exit 1;}; # Get a session id
-
- $targetFile = $ENV{'PATH_TRANSLATED'};
- $ItemID = $in{'ItemID'};
-
- print "Content-Type: text/html\n\n";
- print "<HTML><HEAD><TITLE>$TITLE</TITLE></HEAD><BODY BGCOLOR=#ffffff>";
-
- if (!dbmopen(%subs, "items", 0777)) {
- print "Error: Can not read items database</BODY></HTML>";
- exit 1;
- }
-
- if (!dbmopen(%items, "$Session", 0777)) {
- print "Error: Can not open session data</BODY></HTML>";
- exit 1;
- }
-
- if (!dbmopen(%prices, 'prices', 0777)) {
- print "Error: Can not open price database</BODY></HTML>";
- exit 1;
- }
-
- $totalOrder = $items{'TotalOrder'};
- $totalProducts = $items{'TotalProducts'};
- $totalWeight = $items{'TotalWeight'};
-
- $subItems = $subs{$ItemID};
- if ($subItems != "") {
- for ( $si = 1; $si <= $subItems; $si++ ) {
- $TheSubItem = $ItemID . $si;
- $TheValue = $in{$TheSubItem};
- $totalProducts = $totalProducts - $items{$TheSubItem} + $TheValue; # total # of products ordered
- $totalOrder = $totalOrder + (($TheValue - $items{$TheSubItem}) * $prices{$TheSubItem}); # the total order
- $totalWeight = $totalWeight + (($TheValue - $items{$TheSubItem}) * $prices{$TheSubItem . "W"}); # the total order
- $items{$TheSubItem} = $TheValue;
- } # for
- } # there are sub items
-
- $items{'TotalOrder'} = $totalOrder;
- $items{'TotalWeight'} = $totalWeight;
- $items{'TotalProducts'} = $totalProducts;
-
- dbmclose(%prices);
- dbmclose(%items);
- dbmclose(%subs);
-
- $TargetPage = $in{'TargetPage'};
- $TargetScript = $in{'TargetScript'};
-
- print "The products you specified were marked!<br>";
- print "So far you marked $totalProducts products for a total of \$ $totalOrder <br>";
- print "The total weight of the products you ordered is $totalWeight <br>";
- print "<a href=\"$TargetScript$TargetPage?SessionID=$Session&ItemID=$ItemID\">Continue</a>";
-
- print "</BODY></HTML>";
-
- exit(1);
-
- # GENERAL SUBROUTINES
- # -------------------
-
- sub ReadParse {
- local (*in) = @_ if @_; local ($i, $loc, $key, $val);
- if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; }
- elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); }
- @in = split(/&/,$in);
- foreach $i (0 .. $#in) {
- $in[$i] =~ s/\+/ /g;
- ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
- $key =~ s/%(..)/pack("c",hex($1))/ge;
- $val =~ s/%(..)/pack("c",hex($1))/ge;
- $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
- $in{$key} .= $val;
- }
- return 1; # just for fun
- } # ReadParse
-
- sub PrintError {
- print("Content-Type: text/html\n\n");
- print <<EOF;
- <HTML>
- <HEAD><TITLE>ERROR</TITLE></HEAD>
- <BODY>
- <H1 ALIGN=CENTER>$TITLE</H1> <HR>
- An error occured in the script!
- <HR>
- EOF
- } # PrintError
-
- sub PrintSuccess {
- print <<EOF;
- <HTML>
- <HEAD><TITLE>Success</TITLE></HEAD>
- <BODY>
- <H1 ALIGN=CENTER>$TITLE</H1> <HR>
- Your request was processed succesfuly!
- Thank you for using a catalog maker product!
- <HR>
- EOF
- } # PrintSuccess
-
-